<template>
	<view>
		<scroll-view scroll-y class="page">
			<!-- 头部 -->
			<cu-custom bgColor="bg-rgb" :isBack="true">
				<block slot="backText">返回</block>
				<block slot="content">{{btnType}}项目</block>
			</cu-custom>
			<!-- 数据列表 -->
			<view class="list">
				<view class="card animation-slide-bottom" v-for="(item,index) in list" :key="index" 
				 :style="[{animationDelay: (index + 1)*0.1 + 's'}]">
					<!-- <view class="top">
						<view class="left">移动编号：<text>{{item.mobileCode}}</text></view>
						<view class="right">{{item.mobileType}}</view>
					</view> -->
					<view class="line">
						
					</view>
					<view class="bottom">
						<view class="box">
							<view class="lable">
								料号:
							</view>
							<view class="content">
								{{item.materielCode}}
							</view>
						</view>
						<view class="box">
							<view class="lable">
								名称:
							</view>
							<view class="content">
								{{item.productName}}
							</view>
						</view><view class="box">
							<view class="lable">
								规格:
							</view>
							<view class="content">
								{{item.gauge}}
							</view>
						</view>
						<view class="box">
							<view class="lable">
								数量:
							</view>
							<view class="content">
								{{num}}
							</view>
						</view>
						<view class="box">
							<view class="lable">
								单位:
							</view>
							<view class="content">
								{{item.unit}}
							</view>
						</view>
						<!-- <view class="box">
							<view class="lable">
								预留编号:
							</view>
							<view class="content">
								{{item.reserveCode}}
							</view>
						</view> -->
						<!-- <view class="box">
							<view class="lable">
								工厂:
							</view>
							<view class="content">
								{{item.factoryName}}
							</view>
						</view> -->
						<!-- <view class="box">
							<view class="lable">
								存储位置:
							</view>
							<view class="content">
								{{item.storageSite}}
							</view>
						</view> -->
					</view>
					<view class="line">
						
					</view>
					<view class="btns">
						<view class="btn1" @click="qualityTesting(item)">检验</view>
					</view>
				</view>
			</view>
			<view class="none" v-if="noDataAvailable">
				<view class="none1">
					暂无数据
				</view>
			</view>
			<view class="none2" v-if="noMoreDataAvailable">
				没有更多数据
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		name: 'chooseCheckDetail',
		data() {
			return {
				list: [], // 入库质检数据列表
				pageNo: 1, // 上拉加载 分页
				noDataAvailable: false, // 暂无数据 状态
				noMoreDataAvailable: false, // 没有更多数据 状态
				id:'', // 物料凭证抬头ID
				num: '', // 数量
				btnType: '' // btn类型
			}
		},
		onShow() {
			this.list = []
			this.pageNo = 1
			this.id = uni.getStorageSync('chooseCheckInspectionId'); // 获取缓存中物料凭证抬头Id
			this.num = uni.getStorageSync('chooseCheckInspectionNum'); 
			this.btnType = uni.getStorageSync('chooseCheckInspectionBtnType'); 
			this.getListMesCertificateItemByMainId();
		},
		onPullDownRefresh: function() {
			let _this = this
			_this.pageNo = 1
			_this.list = []
			setTimeout(function() {
				uni.stopPullDownRefresh();
				_this.getListMesCertificateItemByMainId()
			}, 1000);
		},
		onReachBottom: function() {
			let _this = this
			if (this.noDataAvailable == true || this.noMoreDataAvailable == true) {
				return
			}
			_this.pageNo++
			_this.getListMesCertificateItemByMainId()
		},
		methods: {
			// 物料凭证抬头-分页列表查询
			getListMesCertificateItemByMainId() {
				uni.showLoading({
					mask:true,
					title:'加载中.....'
				})
				let data = {
					pageNo: this.pageNo,
					pageSize: 10,
					pCode:this.id,
				}
				// this.$http.get('storage/mesCertificatePerk/listCertificateItemByPerkId', {
				this.$http.get('chiefdata/mesChiefdataMateriel/queryByProductCode', {
					params: data
				}).then(res => {
					uni.hideLoading()
					console.log('this',this)
					this.list = this.list.concat(res.data);
					// if (this.list.length == 0) {
					// 	this.noDataAvailable = true;
					// } else if (this.list.length > 0 && res.data.result.records.length == 0) {
					// 	this.noMoreDataAvailable = true;
					// } else if (res.data.result.total <= this.pageNo * 10) {
					// 	this.noMoreDataAvailable = true;
					// }
					console.log(this.list)
				})
			},
			qualityTesting(item){
				uni.setStorageSync('chooseCheckDetailObj',item);
				this.$Router.push({
					name: 'chooseCheckDetailQuality'
				})
			}
		},
	}
</script>

<style lang="less">
	page {
		background-color: #f1f1f1;
	
		.list {
	
			.card {
				margin: 30rpx;
				box-shadow: 0px 0px 5rpx 2rpx rgba(0, 0, 0, 0.1);
				border-radius: 10rpx;
				background-color: white;
	
				.top {
					display: flex;
					align-items: center;
					justify-content: space-between;
					font-weight: bold;
					padding: 20rpx 30rpx;
	
					.left {
						font-size: 28rpx;
						font-family: PingFang SC;
						font-weight: 400;
						color: #485A75;
						line-height: 50rpx;
					}
	
					.right {
						font-size: 28rpx;
						font-family: PingFang SC;
						font-weight: bold;
						color: #191919;
						line-height: 50rpx;
					}
				}
	
				.line {
					width: 750rpx;
					height: 10rpx;
					background: #F3F5F9;
				}
	
				.bottom {
					padding: 20rpx 30rpx;
	
					.box {
						display: flex;
						justify-content: space-between;
						padding: 20rpx 0;
						align-items: center;
	
						.lable {
							color: #485A75;
							font-size: 28rpx;
						}
	
						.content {
							width: 70%;
							text-align: right;
							color: #191919;
							font-weight: bold;
							word-break: break-all;
						}
					}
				}
	
				.btns {
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding: 0 20rpx;
					font-size: 25rpx;
					padding: 20rpx 30rpx;
	
					view {
						width: 180rpx;
						height: 64rpx;
						line-height: 50rpx;
						color: white;
						border-radius: 30rpx;
						padding: 10rpx 20rpx;
						text-align: center;
					}
	
					.btn1 {
						background-image: radial-gradient(circle, #3F55E9, #5F71ED, #7D8CF0);
						margin-left: 450rpx;
					}
				}
			}
		}
	}
	
	.none .none1 {
		font-size: 30rpx;
		text-align: center;
		margin-top: 50rpx;
		color: #999999;
	}
	
	.none2 {
		font-size: 30rpx;
		text-align: center;
		margin-top: 50rpx;
		color: #999999;
	}
</style>
